//
//  UIResponse+Handler.swift
//  Kaluli
//
//  Created by sun on 2020/11/2.
//  Copyright © 2020 Ranka. All rights reserved.
//

import UIKit

@objc protocol ResponsderHandleProtocol {
    func handleSignal(_ signal: String?,
                      params: Any?) -> Bool
}

extension UIResponder: ResponsderHandleProtocol {
    func handleSignal(_ signal: String?,
                      params: Any?) -> Bool {
        return false
    }

    func triggerSignal(_ signal: String? = nil,
                       params: Any? = nil) {
        var responder = self.next
        while responder != nil {
            if responder?.handleSignal(signal,
                                       params: params) == true { return }
            responder = responder?.next
        }
    }
}
